package sctu.edu.java.year2016.team06.chenqiang.day20160610.chapter15_1;

/**
 * Created by XQ on 2016/6/10.
 * 尝试定义一个继承Thread类的类，并覆盖run方法，在run方法中每隔一百毫秒打印一句话。
 */
public class MyThread extends Thread {
    @Override
    public void run() {
        printf();
    }

    public void printf() {
        for (int i = 0; i < 10; i++) {
            System.out.println("打印一句话：" + i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        myThread.run();
    }
}
